//
//  MTGuideImageView.m
//  MTLayout
//
//  Created by 王慕铁 on 2017/12/13.
//  Copyright © 2017年 王慕铁. All rights reserved.
//

#import "MTGuideImageView.h"

@implementation MTGuideImageView

//图片可能加载失败？？？
+ (MTGuideImageView *)createImage:(NSString *)imageStr {
    
    MTGuideImageView* view = [[self alloc] initWithFrame:ScreenBounds];
    view.backgroundColor = [UIColor clearColor];
    UIWindow* window = [[UIApplication sharedApplication].delegate window];
    [window addSubview:view];

    //找不到图片 直接移除这个View
    if ([UIImage imageNamed:imageStr]) {
        UIImageView* imageView = [[UIImageView alloc] initWithFrame:view.frame];
        imageView.image = [UIImage imageNamed:imageStr];
        [view addSubview:imageView];
    } else {
        [view removeFromSuperview];
    }
    
    return view;
}


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self removeFromSuperview];
    if (_block) {
        _block();
    }
}


@end
